<?php
/*==========================================================================*\
| AGRIVIET - CONTENT MANAGERMENT SYSTEM						
\*==========================================================================*/

	//Xoa nhieu fan tu cung 1 luc
	if (isset($_POST['ButDel'])) {
		$cnt=0;
		foreach ($_POST['chk'] as $id)
		{			

				$result = mysql_query("delete from portfolio where id='".$id."'");
				if ($result) {
					$cnt++;		
			}
		}
		echo "<script>window.location='./?act=portfolio'</script>";
	}
	
	
		
?>
<form method="POST" name="frmList" action="index.php">
<table border="1" cellpadding="2" style="border-collapse: collapse" bordercolor="#D5E2FF" width="100%" id="AutoNumber1">
  <tr>
    <td height="25" colspan="6" align=left class="xtitle">portfolio</td>
    </tr>
  <tr>
    <td align=center class="title"><input type="checkbox" name="chkall" onclick="chkallClick(this);"></td>
    <td align=left class="title" >Title</td>
    <td align="center" nowrap class="title">In stock  </td>
    <td align="center" nowrap class="title">Published</td>
    <td align="center" nowrap class="title">Ordered</td>
    <td align="center" nowrap class="title">Date</td>
    </tr>
<?php
	$sql="select * from portfolio  ";
	$sql.="order by date_add DESC";
	$result=mysql_query($sql);
	$total_records=mysql_num_rows($result);
	$record_per_page=10;
	$scroll=5;
	$page=new Page(); ///creating new instance of Class Page
	$page->set_page_data($urllink,$total_records,$record_per_page,$scroll,true,true,true);
	$page->set_qry_string();
	if($result=mysql_query($page->get_limit_query($sql))){
	$i=0;
	while($row=mysql_fetch_object($result)){
	$i++;
	if ($i%2) $class="le"; else $class="chan";
?>
  <tr class="<?=$class;?>">
    <td align="center">

    <input type="checkbox" name="chk[]" value="<? echo $row->id; ?>"></td>
    <td align="left" >
	<a href="index.php?act=<?=$_GET['act'];?>_m&id=<? echo $row->id; ?>">
	<b><? echo $row->title; ?></b></a></td>

    <td align="center" ><img src="../<? echo $row->image; ?>" /></td>
    <td align="center" >
	<img src="../images/<? echo $row->published; ?>.png" /></td>
    <td align="center" ><? echo $row->ordered; ?> times </td>
    <td align="center" ><? echo date('d - M - Y',$row->date_add); ?></td>
    </tr>

  <?
	}
}
  ?>
</table>

 <input type="hidden" name="act" value="portfolio">
<table border="0" width="100%" cellspacing="0" cellpadding="0" id="table1">
	<tr>
		<td width="50%">

<input type="submit" value="Delete" name="ButDel" onclick="return confirm('B&#7841;n có ch&#7855;c ch&#7855;n mu&#7889;n xoá ?');" class="button">

<input name="ButGood" type="submit" class="button" id="ButGood" value="Feature" />
 <input name="new" type="button" id="new" value="Add new" onclick="window.location='index.php?act=<?=$_GET['act'];?>_m'" class="button" /></td>
        <td width="50%" align="right"><div id="pagenav"><?=$page->get_page_nav();?></div></td>
	</tr>
	<tr>
	  <td colspan="2">&nbsp;</td>
    </tr>
</table>
</form>